<!--修改加盟费表单-->
<template>
  <el-dialog :append-to-body="true" :visible.sync="dialog" title="修改加盟费" width="400px">
    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="100px">
      <el-form-item label="当前加盟费">
        <el-input v-model="nowParticipation" :disabled="true"/>
      </el-form-item>
      <el-form-item label="修改加盟费" prop="participation">
        <el-input v-model="form.participation"/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="cancel">取消</el-button>
      <el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { participationUpdate } from '@/api/partner'
export default {
  props: {
  },
  data() {
    return {
      loading: false, dialog: false,
      //当前加盟费
      nowParticipation: '',
      form: {
        participation: ''
      },
      rules: {
        participation: [
          { required: true, message: '请输入加盟费', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    cancel() {
      this.dialog = false
    },
    doSubmit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.loading = true
          this.doEdit()
        } else {
          return false
        }
      })
    },
    doEdit() {
      participationUpdate(this.form).then(res => {
        this.$notify({
          title: '修改成功',
          type: 'success',
          duration: 2500
        })
        this.loading = false
        this.$parent.init()
        this.dialog = false
      }).catch(err => {
        this.loading = false
        this.dialog = false
        console.log(err.response.data.message)
      })
    }
  }
}
</script>

<style scoped>

</style>
